package ${bao}.${controllerPackage};

import ${bao}.${entityPackage}.${entity};
import ${bao}.${servicePackage}.${entity}Service;
import com.utils.common.ServerResponse;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
* 描述: ${table.comment}
* author: ${author}
* date: ${date}
*/

@RestController
@RequestMapping(value="/${entity?uncap_first}")
public class ${entity}Controller {

    @Autowired
    private ${entity}Service ${entity?uncap_first}Service;

    @GetMapping(value="/list")
    public ServerResponse list(${entity} ${entity?uncap_first}){
        return ${entity?uncap_first}Service.list(${entity?uncap_first});
    }

    @GetMapping(value="/pageList")
    public ServerResponse pageList(${entity} ${entity?uncap_first}){
        return ${entity?uncap_first}Service.pageList(${entity?uncap_first});
    }

    @GetMapping(value = "/get/{id}")
    public ServerResponse getById(@PathVariable String id){
    return ${entity?uncap_first}Service.get(id);
    }

    @PostMapping(value = "/add")
    public ServerResponse add${entity}(@RequestBody @Validated ${entity} ${entity?uncap_first}){
        return ${entity?uncap_first}Service.add${entity}(${entity?uncap_first});
    }

    @PutMapping(value = "/delete/{id}")
    public ServerResponse delete${entity}(@PathVariable String id){
        return ${entity?uncap_first}Service.delete${entity}(id);
    }

    @PostMapping(value = "/update")
    public ServerResponse update${entity}(@RequestBody @Validated ${entity} ${entity?uncap_first}){
        return ${entity?uncap_first}Service.update${entity}(${entity?uncap_first});
    }

}
